$(document).ready(function  () {

	//counter
	$('.counter').countUp({
	    delay: 10,
	    time: 1000
	});
	
	//echarts
	
	var myChart = echarts.init(document.getElementById('main'))
	option = {
    title: {
        text: '2017年公司总盈利',
        subtext: '纯属虚构'
    },
    tooltip: {
        trigger: 'axis'
    },
    
    toolbox: {
        show: true,
        feature: {
            dataZoom: {
                yAxisIndex: 'none'
            },
            dataView: {readOnly: false},
            magicType: {type: ['line', 'bar']},
            restore: {},
            saveAsImage: {}
        }
    },
    xAxis:  {
        type: 'category',
        boundaryGap: false,
        data: data1.month
    },
    yAxis: {
        type: 'value',
        axisLabel: {
            formatter: '{value} ￥'
        }
    },
    series: [
        {
            name:'月利润',
            type:'line',
            data:data1.data,
            markPoint: {
                data: [
                    {type: 'max', name: '最大值'},
                    {type: 'min', name: '最小值'}
                ]
            },
            markLine: {
                data: [
                    {type: 'average', name: '平均值'}
                ]
            }
        },
        
    ]
};
	myChart.setOption(option);
	var myChart2 = echarts.init(document.getElementById('left'));
	var option2 = {
    backgroundColor: '#2c343c',

    title: {
        text: 'Loan cycle',
        left: 'center',
        top: 20,
        textStyle: {
            color: '#ccc'
        }
    },

    tooltip : {
        trigger: 'item',
        formatter: "{a} <br/>{b} : {c} ({d}%)"
    },

    visualMap: {
        show: false,
        min: 20,
        max: 120,
        inRange: {
            colorLightness: [0, 1]
        }
    },
    series : [
        {
            name:'周期',
            type:'pie',
            radius : '55%',
            center: ['50%', '50%'],
            data:data2.sort(function (a, b) { return a.value - b.value; }),
            roseType: 'radius',
            label: {
                normal: {
                    textStyle: {
                        color: 'rgba(255, 255, 255, 0.3)'
                    }
                }
            },
            
            itemStyle: {
                normal: {
                    color: '#c23531',
                    shadowBlur: 200,
                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
            },
            animationType: 'scale',
            animationEasing: 'elasticOut',
            animationDelay: function (idx) {
                return Math.random() * 200;
            }

          	
        }
    ]
};
	myChart2.setOption(option2);
	var myChart3 = echarts.init(document.getElementById('right'));
	var option3 = {
		backgroundColor: '#C5E5EE',
		title:{
                text:'客户贷款金额分布'
            },
	    color: ['#3398DB'],
	    tooltip : {
	        trigger: 'axis',
	        axisPointer : {            // 坐标轴指示器，坐标轴触发有效
	            type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
	        }
	    },
	    
	    xAxis : [
	        {
	            type : 'category',
	            data : data3.money,
	            axisTick: {
	                alignWithLabel: true
	            }
	        }
	    ],
	    yAxis : [
	        {
	            type : 'value'
	        }
	    ],
	    series : [
	        {
	            name:'贷款人数',
	            type:'bar',
	            barWidth: '40%',
	            data: data3.people
	        }
	    ]
	};
	myChart3.setOption(option3);

})


